package events.colors;

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JSlider;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import snazzysprites.SnazzySprites;
import gui.SnazzySpritesGUI;
import state.SnazzySpritesState;
import state.SnazzySpritesStateManager;

/**
 * This handler responds to when the user adjusts the transparency slider. If
 * a shape is selected, it's alpha value is changed to the slider's value.
 * 
 * @author  Richard McKenna
 *          Debugging Enterprises
 * @version 1.0
 */
public class TransparencySliderHandler implements ChangeListener
{
    /**
     * This method responds to when the user adjusts the transparency slider. If
     * a shape is selected, it's alpha value is changed to the slider's value.
     * 
     * @param e The Event Object.
     */
    @Override
    public void stateChanged(ChangeEvent e) {
        JSlider source = (JSlider)e.getSource();
        SnazzySprites singleton = SnazzySprites.getSnazzySprites();
        SnazzySpritesStateManager poseurStateManager = singleton.getStateManager();
        if (poseurStateManager.getMode() == SnazzySpritesState.SHAPE_SELECTED_STATE)
        {
            SnazzySpritesGUI gui = singleton.getGUI();
            if (gui.getAlphaTransparency() < 255)
            {
                int breakpoint = 0;
            }
            poseurStateManager.getSelectedShape().setAlpha(gui.getAlphaTransparency());
            poseurStateManager.refreshState();
        }
    }
}